package com.tueye.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.tueye.annotation.GridClassConfig;
import com.tueye.annotation.GridFieldConfig;
import com.tueye.annotation.ModifyType;
 
/**
 * 注意@ManyToMany/@JoinTable(多对多关系),@OrderBy/LinkedHashSet(集合排序),@Transient(非持久化属性)的应用.
 * @author hanxiaowei
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "tueye_admin_info")
@GridClassConfig(showTitle="管理员列表")
public class Admin {
	
	@GridFieldConfig(modifytype=ModifyType.text,showName="登陆名",size=50,sortable=false)
	private String loginName;
	@GridFieldConfig(modifytype=ModifyType.text,showName="用户姓名",size=50,sortable=false)
	private String username;
	@GridFieldConfig(modifytype=ModifyType.text,showName="昵称",size=50,sortable=false)
	private String byname;
	@GridFieldConfig(modifytype=ModifyType.text,showName="密码",size=50,sortable=false)
	private String password;
	@GridFieldConfig(modifytype=ModifyType.text,showName="是否有效",size=50,sortable=false)
	private Integer isValid;//#0 代表可用,#1代表不可用
	@GridFieldConfig(modifytype=ModifyType.text,showName="email",size=50,sortable=false)
	private String email;
	@GridFieldConfig(modifytype=ModifyType.text,showName="主键",size=50,sortable=true)
	private String id;
	@GridFieldConfig(modifytype=ModifyType.text,showName="填写时间",size=50,sortable=false)
	private Date sys_time;//填写时间
	@GridFieldConfig(modifytype=ModifyType.text,showName="填写人",size=50,sortable=false)
	private String sys_fille;//填写人
	
	@Id
	@Column(name="id", length = 40)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sys_time", length = 7)
	public Date getSys_time() {
		return sys_time;
	}

	public void setSys_time(Date sys_time) {
		this.sys_time = sys_time;
	}
	 @Column(name = "sys_fille", length = 40)
	 public String getSys_fille() {
		return sys_fille;
	}

	public void setSys_fille(String sys_fille) {
		this.sys_fille = sys_fille;
	}

	// add by  yue . 2008/12/21 you can see the folds doc.
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		
		if(this == obj) return true;
		
		if(!(obj  instanceof BaseEntity))
			 return false;
		// if not through Above ,will throw excption of  ClassCaseException
		BaseEntity entiry = (BaseEntity)obj;
		
		if(this.getId() != null && this.getId().length()>0 ){
			return this.getId().equals(entiry.getId());
		}
		 // if don't execute Above,that this.id is null or.. so if enrity.getId != null will 
		 //  return false
		if(entiry.getId() != null && entiry.getId().length()>0 ){
			return false;
		}
		//about EqualsBuilder you can see the doc..
		return EqualsBuilder.reflectionEquals(this, entiry);
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		if(this.getId() != null && this.getId().length()>0){
			return this.getId().hashCode();
		}
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		 return ReflectionToStringBuilder.toString(this);
	}
	
	
	
	@Column(name = "username", length = 40)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	@Column(name = "byname", length = 40)
	public String getByname() {
		return byname;
	}

	public void setByname(String byname) {
		this.byname = byname;
	}

	@Column(name = "password", length = 30)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "isValid", length = 10)
	public Integer getIsValid() {
		return isValid;
	}

	public void setIsValid(Integer isValid) {
		this.isValid = isValid;
	}
	@Column(name = "loginName", length = 30)
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	@Column(name = "email", length = 20)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
 

}